]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
searchDisplay: Make the search result actors stateless, by removing terms
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 9 Feb 2013 00:04:24 +0000 (19:04 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Wed, 30 Oct 2013 17:01:20 +0000 (13:01 -0400)
We want to cache result actors between searches, so we shouldn't
instantiate them with search-specific info.

https://bugzilla.gnome.org/show_bug.cgi?id=704912

js/ui/appDisplay.js
js/ui/search.js

index 2889aba616286113353d605b3e4096a27e19d1dc..cc711bd406539f2bedf6fec72d5fc65a0706e708 100644 (file)
@@ -914,7 +914,7 @@ const AppSearchProvider = new Lang.Class({
         app.open_new_window(workspace);
     },
 
-    createResultObject: function (resultMeta, terms) {
+    createResultObject: function (resultMeta) {
         let app = this._appSys.lookup_app(resultMeta['id']);
         return new AppIcon(app);
     }
index b6da0e904a284e4557c29b3c5f3ddba3ab51cf89..7cd2195575961580264fcbc452185558ea3076ab 100644 (file)
@@ -167,10 +167,9 @@ const MaxWidthBin = new Lang.Class({
 const SearchResult = new Lang.Class({
     Name: 'SearchResult',
 
-    _init: function(provider, metaInfo, terms) {
+    _init: function(provider, metaInfo) {
         this.provider = provider;
         this.metaInfo = metaInfo;
-        this.terms = terms;
 
         this.actor = new St.Button({ reactive: true,
                                      can_focus: true,
@@ -179,12 +178,11 @@ const SearchResult = new Lang.Class({
                                      y_fill: true });
 
         this.actor._delegate = this;
-        this.actor.connect('clicked', Lang.bind(this, this.activate));
+        this.actor.connect('clicked', Lang.bind(this, this._activate));
     },
 
-    activate: function() {
-        this.provider.activateResult(this.metaInfo.id, this.terms);
-        Main.overview.toggle();
+    _activate: function() {
+        this.emit('activate', this.metaInfo.id);
     },
 
     setSelected: function(selected) {
@@ -194,6 +192,7 @@ const SearchResult = new Lang.Class({
             this.actor.remove_style_pseudo_class('selected');
     }
 });
+Signals.addSignalMethods(SearchResult.prototype);
 
 const ListSearchResult = new Lang.Class({
     Name: 'ListSearchResult',
@@ -201,8 +200,8 @@ const ListSearchResult = new Lang.Class({
 
     ICON_SIZE: 64,
 
-    _init: function(provider, metaInfo, terms) {
-        this.parent(provider, metaInfo, terms);
+    _init: function(provider, metaInfo) {
+        this.parent(provider, metaInfo);
 
         this.actor.style_class = 'list-search-result';
         this.actor.x_fill = true;
@@ -246,12 +245,12 @@ const GridSearchResult = new Lang.Class({
     Name: 'GridSearchResult',
     Extends: SearchResult,
 
-    _init: function(provider, metaInfo, terms) {
-        this.parent(provider, metaInfo, terms);
+    _init: function(provider, metaInfo) {
+        this.parent(provider, metaInfo);
 
         this.actor.style_class = 'grid-search-result';
 
-        let content = provider.createResultObject(metaInfo, terms);
+        let content = provider.createResultObject(metaInfo);
         let dragSource = null;
 
         if (content == null) {
@@ -343,6 +342,10 @@ const SearchResultsBase = new Lang.Class({
         this.emit('key-focus-in', actor);
     },
 
+    _activateResult: function(result, id) {
+        return this.provider.activateResult(id, this._terms);
+    },
+
     _setMoreIconVisible: function(visible) {
     },
 
@@ -413,7 +416,8 @@ const ListSearchResults = new Lang.Class({
 
     _renderResults: function(metas) {
         for (let i = 0; i < metas.length; i++) {
-            let display = new ListSearchResult(this.provider, metas[i], this._terms);
+            let display = new ListSearchResult(this.provider, metas[i]);
+            display.connect('activate', Lang.bind(this, this._activateResult));
             display.actor.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
             this._content.add_actor(display.actor);
         }
@@ -453,7 +457,8 @@ const GridSearchResults = new Lang.Class({
 
     _renderResults: function(metas) {
         for (let i = 0; i < metas.length; i++) {
-            let display = new GridSearchResult(this.provider, metas[i], this._terms);
+            let display = new GridSearchResult(this.provider, metas[i]);
+            display.connect('activate', Lang.bind(this, this._activateResult));
             display.actor.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
             this._grid.addItem(display);
         }